<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title><fmt:message key="rental" /> <fmt:message key="numberShort" /> <c:out value="${rental.id}"/> - 
            <c:out value="${rental.customer.firstName}"/> <c:out value="${rental.customer.lastName}"/></title>
    </head>
    <body>
        <div class="container">
            <c:if test="${null == rental}">
                <img src="<c:url value="/resources/pictures/error.png" />" title="<fmt:message key="rental.notFound" />" />
                <b><fmt:message key="rental.notFound" /></b>
            </c:if>
            <c:if test="${null != rental}">
                <h1><fmt:message key="rental" /> <fmt:message key="numberShort" /> <c:out value="${rental.id}"/> - 
                    <c:out value="${rental.customer.firstName}"/> <c:out value="${rental.customer.lastName}"/></h1>

                <sec:authorize access="hasRole('ROLE_ADMIN')">
                    <div>
                        <a href="<c:url value="/rental/remove/${rental.id}"/>" onclick="return confirm('<fmt:message key="remove.confirm" />')">
                            <img src="<c:url value="/resources/pictures/remove.png" />" title="<fmt:message key="remove" />" /> <fmt:message key="remove" />
                        </a>
                    </div>
                </sec:authorize>

                <table class="table">
                    <tr>
                        <td><b><fmt:message key="customer" /></b></td>
                        <td><c:out value="${rental.customer.firstName}"/> <c:out value="${rental.customer.lastName}"/></td>
                    </tr>
                    <tr>
                        <td><b><fmt:message key="machine" /></b></td>
                        <td><c:out value="${rental.machine.code}"/> - <c:out value="${rental.machine.brand}"/> <c:out value="${model.rental.machine.model}"/></td>
                    </tr>
                    <tr>
                        <td><b><fmt:message key="rental.dateOfRent" /></b></td>
                        <td><c:out value="${rental.dateOfRent}"/></td>
                    </tr>
                    <tr>
                        <td><b><fmt:message key="rental.duration" /></b></td>
                        <td><c:out value="${rental.duration}"/></td>
                    </tr>
                    <tr>
                        <td><b><fmt:message key="rental.dateOfReturn" /></b></td>
                        <td><c:out value="${rental.dateOfReturn}"/></td>
                    </tr>

                    <tr>
                        <td>
                            <a href="<c:url value="/rental/index"/>" ><fmt:message key="rental.backToListOfRentals" /></a>
                        </td>
                        <td>
                            <a href="<c:url value="/rental/edit/${rental.id}"/>"> 
                                <img src="<c:url value="/resources/pictures/edit.png" />" title="<fmt:message key="edit" />" /> <fmt:message key="edit" />
                            </a>
                        </td>
                    </tr>
                </table>
            </c:if>
        </div>
    </body>
</html>
